package com.lxw.manage.course.service;

import com.lxw.framework.domain.course.CourseMarket;
import com.lxw.framework.model.response.CommonCode;
import com.lxw.framework.model.response.ResponseResult;
import com.lxw.manage.course.dao.CourseMarketRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Optional;

@Service
public class CourseMarketServiceImpl implements ICourseMarketService{

    @Autowired
    CourseMarketRepository courseMarketRepository;


    @Override
    public CourseMarket getCourseMarketById(String courseId) {

        //课程id和营销id 保持一致
        Optional<CourseMarket> byId = courseMarketRepository.findById(courseId);
        if (byId.isPresent()){
            return byId.get();
        }
        return null;
    }

    @Override
    public ResponseResult updateCourseMarket(CourseMarket courseMarket) {
        CourseMarket save = courseMarketRepository.save(courseMarket);
        ResponseResult responseResult = new ResponseResult(CommonCode.SUCCESS);

        return responseResult;
    }
}
